<?php

namespace app\admin\controller;

use app\admin\service\LineService;

class LineController extends CommonController
{
    // 获取线路的分页列表
    public function getLineList($_type){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(LineService::class, [$this->returnData, $_type, $this->params]);
        $this->returnData = $service->getList();
        return $this->return_result($this->returnData);
    }

    // 添加线路
    public function toAddLine($_type){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(LineService::class, [$this->returnData, $_type, $this->params]);
        $this->returnData = $service->toAdd();
        return $this->return_result($this->returnData);
    }

    // 更新线路
    public function toUpdateLine($_type){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(LineService::class, [$this->returnData, $_type, $this->params]);
        $this->returnData = $service->toUpdate();
        return $this->return_result($this->returnData);
    }

    // 线路的详细内容
    public function getLineDetail($_type){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(LineService::class, [$this->returnData, $_type, $this->params]);
        $this->returnData = $service->getDetail();
        return $this->return_result($this->returnData);
    }

    // 修改线路状态
    public function toChangeStatusLine($_type){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(LineService::class, [$this->returnData, $_type, $this->params]);
        $this->returnData = $service->toChangeStatus();
        return $this->return_result($this->returnData);
    }

    // 修改线路是否热门
    public function toIsHotLine($_type){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(LineService::class, [$this->returnData, $_type, $this->params]);
        $this->returnData = $service->toIsHot();
        return $this->return_result($this->returnData);
    }

    // 删除线路
    public function toDelLine($_type){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(LineService::class, [$this->returnData, $_type, $this->params]);
        $this->returnData = $service->toDel();
        return $this->return_result($this->returnData);
    }

}